<?php  
class ControllerModuleArticleFreeDownload extends Controller {
	protected function index() {
	if($this->config->get('config_news_installed')==1){
		$this->language->load('module/article_free_download');
		
    	$this->data['heading_title'] = $this->language->get('heading_title');
		
		$this->load->model('news/article');
				
		$downloads = explode(',', $this->config->get('config_free_download'));
		$this->data['downloads'] = array();
		
		foreach ($downloads as $download_id) {
			$download_info = $this->model_news_article->getFreeDownload($download_id);
			
			if ($download_info) {
					if (file_exists(DIR_IMAGE.'icon/'.substr(strrchr($download_info['mask'], '.'), 1).'.png')) {
					$ext=HTTPS_SERVER.'image/icon/'.substr(strrchr($download_info['mask'], '.'), 1).'.png';
					}else{
					$ext=HTTPS_SERVER.'image/icon/file.png';	
					}
				$this->data['downloads'][] = array(
				'name' => $download_info['name'],		
				'mask' => $download_info['mask'],		
				'thumb' => $ext,		
				'href' => $this->url->link('news/article/download','&auth_key=' . $download_info['auth_key']),			
				);
			}
		}	
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/blog/article_free_download.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/blog/article_free_download.tpl';
		} else {
			$this->template = 'default/template/module/blog/article_free_download.tpl';
		}
		
		$this->render();
	}
	}
}
?>